[TOC]

Basic Concept

There are two types of operators, namely, unary and binary operators. For examples,

Unary Operators

A unary operator requires just one operand. The following shows unary operators supported in the app.

OperatorOperationExamples
+Unary plus+2, -[1 2; 3 4]
-Unary minus-1, -[1 2; 3 4]
'Conjugate transposeones(2,3)'
.'Transposeones(2,3).'
!, ~Logical NOT~true, !(1 > 4)

Unary operators are operated in element-wise manner. That means, it is applied to each of the elements in an array individually.

Binary Operators

A majority of operators in this app are binary. It has two operands, for examples,

The operands should have compatible sizes as explained below. Otherwise, the operation cannot be performed.

Compatible Sizes

A binary operator may perform an element-wise operation or a matrix operation. When an element-wise operation is performed, the two operands must have compatible sizes. In the following example, two arrays of compatible sizes are added using the addition operator.

A = ones(2,3,4);
B = rand(2,3,4);
C = A + B

In the above example, two arrays A and B are added to give C. The addition is performed in an element-wise fashion. That is, each element of A is added to the element of B at the same position, i.e., A(i) + B(i) for all i. It is usually expected that size(A, i) and size(B, i) are the same for all i, so that the size of the result, size(C, i), can be inferred. However, if size(A, i) and size(B, i) are different, size(C, i) can still be inferred when either size(A, i) == 1 or size(B, i) == 1 holds. In this situation, the dimension of unit length is expanded to match the length of the other array.

The arrays A and B have compatible sizes if at least one of the following is satisfied for all i equal to 1, 2, ..., max(ndim(A), ndim(B)).

  1. size(A, i) == size(B, i)
  2. size(A, i) == 1
  3. size(B, i) == 1

Otherwise, A and B are said to have incompatible sizes.

Examples

Input
1 + rand(3,4)
Output
ans = 
 1.2533   1.1439   1.3350   1.3325
 1.6077   1.2538   1.0825   1.6245
 1.1383   1.2089   1.7501   1.9005
Input
ones(3,1) + rand(3,4)
Output
ans = 
 1.4848   1.0346   1.3401   1.2939
 1.2790   1.9602   1.2750   1.1826
 1.9858   1.4399   1.9184   1.1713
Input
ones(2,3) + rand(2,3,4)
Output
ans(:, :, 1) = 
 1.3650   1.9548   1.1026
 1.2504   1.1537   1.8637

ans(:, :, 2) = 
 1.6086   1.3317   1.6006
 1.9093   1.3834   1.1635

ans(:, :, 3) = 
 1.9176   1.5907   1.3863
 1.0363   1.6654   1.2127

ans(:, :, 4) = 
 1.2852   1.8740   1.8748
 1.1846   1.9509   1.0385

Matrix Operators

Some operators by default perform matrix operations when both of the operands are matrices having the correct sizes. For example, [1 2] * [1 2; 3 4] performs matrix multiplication that gives the array [7, 10].

The following is a list of all matrix operations supported by SIMO. Each of the operations performs the following size check:

Matrix OperationOperator
Power^
Solving matrix equation \
Multiplication*
Solving the matrix equation /
Conjugate transpose'
Non-conjugate transpose.'